{extend name="public:base"}
{block name="js"}
<script type="text/javascript" src="__PUBLIC__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/hplus.min.js?v=4.1.0"></script>
<script type="text/javascript" src="__PUBLIC__/js/contabs.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/plugins/pace/pace.min.js"></script>
<script src="__PUBLIC__/js/plugins/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/plugins/validate/messages_zh.min.js"></script>
<script type="text/javascript">
    //获取下级市列表
    function getAjaxRegion(id,name){
        if(!id){
            return false;
        }
        $.ajax( {
            url:"{:url('Index/getAjaxRegion')}",
            data:{
                'id' : id
            },
            type:'get',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.status == 'y'){
                    var html='<option value="">请选择</option>';
                    for(var i in data.data){
                        html+='<option value="'+data.data[i].id+'">'+data.data[i].title+'</option>';
                    }
                    if(data.data.length){
                        $("select[name='"+name+"']").html(html);
                    }else{
                        $("select[name='"+name+"']").html('<option value="">没有找到城市！</option>');
                    }
                }else{
                    alert(data.message);
                }
            }
        });
    }


    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });
    $().ready(function() {
        var e = "<i class='fa fa-times-circle'></i> ";
        $("#saveInfo").validate({
            rules: {
                truename: "required",
                tel: "required",
                username:{
                    required:true,
                    minlength:3
                }
            },
            messages: {
                truename: e + "请输入姓名",
                tel: e + "请输入联系电话",
                username:{
                    required:e + "请输入登录帐号",
                    minlength:e + "登录帐号长度最小为3"
                }
            },
            submitHandler: function(form){
                if ($(form).hasClass('ed')) {
                    return false;
                }

                $(form).addClass('ed');
                var obj = showMyLoading();
                $.post("{:url('saveInfo')}", $(form).serialize(), function(data){
                    hideMyLoading(obj);
                    layer.msg(data.info);
                    if (data.status == 'y') {
                        setTimeout(function(){
                            window.location.href = '{:url("index")}';
                        }, 1500);
                    } else {
                        $(form).removeClass('ed');
                    }
                }, 'json');
            }
        });
        $("#savePass").validate({
            rules: {
                password: "required",
                onepassword: {
                    required: true,
                    minlength: 5
                },
                twopassword:  {
                    required: true,
                    equalTo: '#onepassword'
                }
            },
            messages: {
                password: e + "请输入原密码",
                onepassword: {
                    required:e + "请输入新密码",
                    minlength:e + "密码长度不能少于5"
                },
                twopassword: {
                    required:e + "请再次输入新密码",
                    equalTo: e + "两次密码输入不一致"
                }
            },
//            showErrors: function (errorMap, errorList) {
//                var msg = "";
//                $.each(errorList, function (i, v) {
//                    layer.msg(v.message);
//                    return false;
//                });
//            },
            submitHandler: function(form){
                if ($(form).hasClass('ed')) {
                    return false;
                }

                $(form).addClass('ed');
                var obj = showMyLoading();
                $.post("{:url('savePass')}", $(form).serialize(), function(data){
                    hideMyLoading(obj);
                    layer.msg(data.info);
                    if (data.status == 'y') {
                        setTimeout(function(){
                            window.location.href = '{:url("index")}';
                        }, 1500);
                    } else {
                        $(form).removeClass('ed');
                    }
                }, 'json');
            }
        });

        $('#head_img').change(function(event) {
            var self = this;
            var files = event.target.files || event.dataTransfer.files;
            var formData = new FormData();
            formData.append('imgFile', files[0]);
            var ajax = new XMLHttpRequest();
            ajax.open("POST", "{:url('index/Index/saveImg')}", true);
            ajax.send(formData);
            ajax.onreadystatechange = function() {
                if (ajax.readyState == 4) {
                    if (ajax.status >= 200 && ajax.status < 300 || ajax.status == 304) {
                        var data = JSON.parse(ajax.responseText);
                        if (data.status == 'y') {
                            $(self).next().val(data.data.src);
                            $(self).parent().next().find('img').attr('src', data.data.src);
                        } else {
                            layer.msg(data.info);
                        }
                    }
                }
            }
        });
    });
</script>

<script type="text/javascript">
    //自动收货等
    // function automatic(){
    //     $.ajax({
    //         url:"{:url('automatic')}",
    //         type:'post',
    //         cache:false,
    //         dataType:'json',
    //         async:false,
    //         success:function(data) {
    //         }
    //     });

    //     setTimeout("automatic()",1000*60);

    // }
    //setTimeout('automatic()',5000);

    //登录超时
    function checkLocks(){
        $.ajax({
            url:"{:url('Login/check_locks')}",
            cache:false,
            dataType:'json',
            async:false,
            success:function(data) {
                if(data.status == 'n'){
                    self.location = '{:url("Login/locks")}';
                }
            }
        });
    }
    setTimeout("checkLocks()",1000*10);
</script>
{/block}
{block name="body"}
<body class="fixed-sidebar full-height-layout gray-bg skin-1" style="overflow:hidden">
    <div id="wrapper">
        <!--左侧导航开始-->
        <nav class="navbar-default navbar-static-side" role="navigation">
            <div class="nav-close"><i class="fa fa-times-circle"></i>
            </div>
            <div class="sidebar-collapse">
                <ul class="nav" id="side-menu">
                    <li class="nav-header">
                        <div class="dropdown profile-element">
                            <span><img alt="image" class="img-circle" src="{$manageInfo.img}" style="width:64px;height:64px;"/></span>
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <span class="clear">
                               <span class="block m-t-xs"><strong class="font-bold">{$manageInfo.truename}</strong></span>
                                <span class="text-muted text-xs block">{$manageInfo.groupname}<b class="caret"></b></span>
                                </span>
                            </a>
                            <ul class="dropdown-menu animated fadeInRight m-t-xs">
                                <li><a href="javascript:;" data-toggle="modal" data-target="#myInfo" >修改资料</a></li>
                                <li><a href="javascript:;" data-toggle="modal" data-target="#myPass">修改密码</a></li>
                            </ul>
                        </div>
                        <div class="logo-element"><a href=""><img src="__PUBLIC__/img/successs.png" /></a>
                        </div>
                    </li>
					<li>
						<a class="J_menuItem" href="{:url('Index/panel')}" data-index="0"><i class="fa fa-home"></i> <span class="nav-label">首页</span></a>
                    </li>
                        
						{:linkKJ($link,false,[],$newclass)}

                </ul>
            </div>
        </nav>
        <!--左侧导航结束-->
        <!--右侧部分开始-->
        <div id="page-wrapper" class="gray-bg dashbard-1">
            <div class="row border-bottom">
                <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                    <div class="navbar-header">
						<a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
                    </div>
                    <ul class="nav navbar-top-links navbar-right" >

                        <!--<li class="dropdown">-->
                            <!--<a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">-->
                                <!--<i class="fa fa-bell"></i> <span class="label label-warning newCount">0</span>通知-->
                            <!--</a>-->
                            <!--<ul class="dropdown-menu dropdown-alerts" style="width:250px;">-->
                                <!--<li>-->
                                    <!--<a href="javascript:onclickMenu('{:url('Order/index')}');">-->
                                        <!--<div>-->
                                            <!--<i class="fa fa-envelope fa-fw"></i> 待发货订单：<span class="label label-warning pull-right newOrder">0</span>-->
                                        <!--</div>-->
                                    <!--</a>-->
                                <!--</li>-->
                                <!--<li class="divider"></li>-->
                                <!--<li>-->
                                    <!--<a href="javascript:onclickMenu('{:url('Integralorder/index')}');">-->
                                        <!--<div>-->
                                            <!--<i class="fa fa-envelope fa-fw"></i> 新的积分兑换申请：<span class="label label-warning pull-right integralNewOrder">0</span>-->
                                        <!--</div>-->
                                    <!--</a>-->
                                <!--</li>-->
                                <!--<li class="divider"></li>-->
								<!--<li>-->
                                    <!--<a href="javascript:onclickMenu('{:url('Integralorder/index')}');">-->
                                        <!--<div>-->
                                            <!--<i class="fa fa-envelope fa-fw"></i> 积分兑换待发货订单：<span class="label label-warning pull-right integralFaOrder">0</span>-->
                                        <!--</div>-->
                                    <!--</a>-->
                                <!--</li>-->
                                <!--<li class="divider"></li>-->
								<!--<li>-->
                                    <!--<a href="javascript:onclickMenu('{:url('Message/index')}');">-->
                                        <!--<div>-->
                                            <!--<i class="fa fa-envelope fa-fw"></i> 新的意见反馈：<span class="label label-warning pull-right messageCount">0</span>-->
                                        <!--</div>-->
                                    <!--</a>-->
                                <!--</li>-->
								<!--<li class="divider" style="margin-right:0px;"></li>-->
                            <!--</ul>-->
                        <!--</li>-->

						<script type="text/javascript">
							function newOrderCount(){
								$.ajax({  
    								url:"{:url('newCount')}",
     								type:'post',  
     								cache:false,  
     								dataType:'json', 
									async:false,				
     								success:function(data) {  
         	 	 	 	 	 			$('.newOrder').text(data.newOrder);
         	 	 	 	 	 			$('.integralNewOrder').text(data.integralNewOrder);
										$('.integralFaOrder').text(data.integralFaOrder);
										$('.messageCount').text(data.messageCount);
										$('.newCount').text(data.newCount);
      								} 
 								});
								
								setTimeout("newOrderCount()",1000*60);
								
							}
							
							//newOrderCount();

                            // function automatic(){
                            //     $.post("{:url('autoIntegral')}");
                            //     $.post("{:url('autoOrder')}");
                            //     setTimeout("automatic()",1000*60);
                            // }
                            // automatic();
							
							//点击
							function onclickMenu(url){
								$("#side-menu a[href='"+url+"']").click();
							}
						</script>
						<li class="hidden-xs">
                            <a href="javascript:$('.J_menuTab.active').dblclick();" ><i class="fa fa-refresh"></i>刷新</a>
                        </li>
						<!--<li class="dropdown hidden-xs">-->
                            <!--<a class="right-sidebar-toggle" aria-expanded="false">-->
                                <!--<i class="fa fa-tasks"></i>主题-->
                            <!--</a>-->
                        <!--</li>-->
                        <li class="hidden-xs">
                            <a href="{:url('Index/index')}" ><i class="fa fa-home"></i>首页</a>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="row content-tabs">
                <button class="roll-nav roll-left J_tabLeft"><i class="fa fa-backward"></i>
                </button>
                <nav class="page-tabs J_menuTabs">
                    <div class="page-tabs-content">
                        <a href="javascript:;" class="active J_menuTab" data-id="{:url('Index/panel')}">首页</a>
                    </div>
                </nav>
                <button class="roll-nav roll-right J_tabRight"><i class="fa fa-forward"></i>
                </button>
                <div class="btn-group roll-nav roll-right">
                    <button class="dropdown J_tabClose" data-toggle="dropdown">关闭操作<span class="caret"></span>

                    </button>
                    <ul role="menu" class="dropdown-menu dropdown-menu-right">
                        <li class="divider"></li>
                        <li class="J_tabCloseAll"><a>关闭全部选项卡</a>
                        </li>
                        <li class="J_tabCloseOther"><a>关闭其他选项卡</a>
                        <li class="divider"></li>
                        </li>
                    </ul>
                </div>
                <a href="{:url('Login/logout')}" class="roll-nav roll-right J_tabExit"><i class="fa fa fa-sign-out"></i> 退出</a>
            </div>
            <div class="row J_mainContent" id="content-main">
                <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="{:url('Index/panel')}" frameborder="0" data-id="{:url('Index/panel')}" seamless></iframe>
            </div>
            
        </div>
        <!--右侧部分结束-->
        <!--右侧边栏开始-->
        <div id="right-sidebar">
            <div class="sidebar-container">

                <ul class="nav nav-tabs navs-3">

                    <li class="active">
                        <a data-toggle="tab" href="#tab-1">
                            <i class="fa fa-gear"></i> 主题
                        </a>
                    </li>
			
                </ul>

                <div class="tab-content">
                    <div id="tab-1" class="tab-pane active">
                        <div class="sidebar-title">
                            <h3> <i class="fa fa-comments-o"></i> 主题设置</h3>
                            <small><i class="fa fa-tim"></i> 你可以从这里选择和预览主题的布局和样式，这些设置会被保存在起来，下次打开的时候会直接应用这些设置。</small>
                        </div>
                        <div class="skin-setttings">
                            <div class="title">主题设置</div>
                            <div class="setings-item">
                                <span>收起左侧菜单</span>
                                <div class="switch">
                                    <div class="onoffswitch">
                                        <input type="checkbox" name="collapsemenu" class="onoffswitch-checkbox" id="collapsemenu">
                                        <label class="onoffswitch-label" for="collapsemenu">
                                            <span class="onoffswitch-inner"></span>
                                            <span class="onoffswitch-switch"></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="setings-item">
                                <span>固定顶部</span>
                                <div class="switch">
                                    <div class="onoffswitch">
                                        <input type="checkbox" name="fixednavbar" class="onoffswitch-checkbox" id="fixednavbar">
                                        <label class="onoffswitch-label" for="fixednavbar">
                                            <span class="onoffswitch-inner"></span>
                                            <span class="onoffswitch-switch"></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <div class="setings-item">
                                <span>
                                    固定宽度
                                </span>
                                <div class="switch">
                                    <div class="onoffswitch">
                                        <input type="checkbox" name="boxedlayout" class="onoffswitch-checkbox" id="boxedlayout">
                                        <label class="onoffswitch-label" for="boxedlayout">
                                            <span class="onoffswitch-inner"></span>
                                            <span class="onoffswitch-switch"></span>
                                        </label>
                                    </div>
                                </div>
                            </div>
							
                        </div>
                    </div>
					
                </div>

            </div>
        </div>
        <!--右侧边栏结束-->
    </div>
	<!--修改资料-->
	<div class="modal inmodal" id="myInfo" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content animated bounceInRight">
                <div class="modal-header" style="padding:15px;">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                    </button>
                    <h4 class="modal-title" style="font-size:20px;">修改资料</h4>
                </div>
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="saveInfo" enctype="multipart/form-data" method="post">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">姓名：</label>
                                <div class="col-sm-8">
                                    <input name="truename" class="form-control" type="text" value="{$manageInfo.truename}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">联系电话：</label>
                                <div class="col-sm-8">
                                    <input name="tel" class="form-control" type="text" value="{$manageInfo.tel}">
                                </div>
                            </div>
							<div class="form-group">
                                <label class="col-sm-3 control-label">登录帐号：</label>
                                <div class="col-sm-8">
                                    <input name="username" class="form-control" type="text" value="{$manageInfo.username}">
                                </div>
                            </div>
							<div class="form-group">
                                <label class="col-sm-3 control-label">头像：</label>
                                <div class="col-sm-6">
									<input class="form-control" type="file" id="head_img" style="padding:0px;">
                                    <input type="hidden" name="img" value="{$manageInfo.img}"/>
									<span class="help-block m-b-none">头像大小（100px * 100px）</span>
                                </div>
                                <div class="col-sm-2">
									<a href="{$manageInfo.img}" target="_blank">
										<img src="{$manageInfo.img}" style="width:50px;height:50px;border-radius:25px;" />
									</a>
                                </div>
                            </div>
							<div class="form-group">
                                <label class="col-sm-3 control-label">省市区：</label>
                                <div class="col-sm-8">
                                	<div class="col-sm-4" style="padding-left:0px;">
										<select class="form-control m-b" name="sheng_id" onchange="getAjaxRegion(this.value,'city_id')" style="margin-bottom:0px;">
											<option value="">请选择省！</option>
											{volist name="shengList" id="sheng"}
	                                         	<option value="{$sheng.id}" {if condition="$sheng['id'] eq $manageInfo['sheng_id']"}selected="selected"{/if} >{$sheng.title}</option>
                                        	{/volist}
										</select>
									</div>
									<div class="col-sm-4" style="padding-left:0px;">
										<select class="form-control m-b" name="city_id" onchange="getAjaxRegion(this.value,'area_id')" style="margin-bottom:0px;">
											<option value="">请选择市！</option>
											{volist name="cityList" id="city"}
                                         		<option value="{$city.id}" {if condition="$city['id'] eq $manageInfo['city_id']"}selected="selected"{/if}>{$city.title}</option>
                                        	{/volist}
										</select>
									</div>
									<div class="col-sm-4" style="padding:0px;">
										<select class="form-control m-b" name="area_id" style="margin-bottom:0px;">
											<option value="">请选择区！</option>
											{volist name="areaList" id="area"}
                                         		<option value="{$area.id}" {if condition="$area['id'] eq $manageInfo['area_id']"}selected="selected"{/if}>{$area.title}</option>
                                        	{/volist}
										</select>
									</div>
                                </div>
                            </div>
							<div class="form-group">
                                <label class="col-sm-3 control-label">街道地址：</label>
                                <div class="col-sm-8">
                                    <input name="address" class="form-control" type="text" value="{$manageInfo.address}">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-8 col-sm-offset-3">
                                    <button class="btn btn-primary" type="submit">提交</button>
                                </div>
                            </div>
                        </form>
                    </div>
            </div>
        </div>
    </div>


	<!--修改密码-->
	<div class="modal inmodal" id="myPass" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content animated bounceInRight">
                <div class="modal-header" style="padding:15px;">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                    </button>
                    <h4 class="modal-title" style="font-size:20px;">修改密码</h4>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="savePass"  method="post">
						<div class="form-group">
                            <label class="col-sm-3 control-label">用户账号：</label>
                            <div class="col-sm-8">
                                <input name="username" disabled value="{$manageInfo.username}" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">原密码：</label>
                            <div class="col-sm-8">
                                <input name="password" class="form-control" type="password">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">新密码：</label>
                            <div class="col-sm-8">
                                <input  name="onepassword" id="onepassword" class="form-control" type="password">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">确认密码：</label>
                            <div class="col-sm-8">
                                <input name="twopassword" class="form-control" type="password">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
{/block}
